package ljl.alg.wangzheng_camp.round1.hashmap;

import java.util.Arrays;

public class _706_my_hashmap {
    
    class MyHashMap {
        static int MAX = 10_0000_00;
        static int INITIAL = 16;
        int[] map;
        public void put(int key, int value) {
            if (map == null) {
                map = new int[Math.min(MAX, Math.max(key * 2, INITIAL))];
                Arrays.fill(map, -1);
            } else if (key >= map.length) {
                int newLen = Math.min(key * 2, MAX);
                int oldLen = map.length;
                map = Arrays.copyOf(map, newLen);
                Arrays.fill(map, oldLen, newLen, -1);
            }
            map[key] = value;
        }
    
        public int get(int key) {
            return map == null || key >= map.length ? -1 : map[key];
        }
    
        public void remove(int key) {
            if (map != null && key < map.length) {
                map[key] = -1;
            }
        }
    }
    
}
